home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / doc / arch_overview.3.0.me next >
Encoding:
Text File  |  1996-05-05  |  33.0 KB  |  817 lines

  1. .\" use larger type so that it looks OK after photo-reducing
  2. .nr pp 11\" use larger point size
  3. .nr sp 11\" yep, I really mean it
  4. .nr tp 11\" and I'll mean it after other stuff
  5. .nr fp 9\" don't reset to 10 point (and use 9 footnotes)
  6. .sz 11\" believe me!!!
  7. .EQ
  8. gsize 11
  9. gfont R
  10. delim @@
  11. .EN
  12. .ds V "3.0
  13. .\"
  14. .\" EXODUS Storage Manager Architecture Overview
  15. .\"
  16. .po 1.0i
  17. .ll 6.5i
  18. .ls 2
  19. .ce 2
  20. .sz 13
  21. \fBEXODUS Storage Manager\**  V\*V Architecture Overview\fR
  22. .sz 12
  23. (Last revision: April, 1993)
  24. .sp 3
  25. .(f
  26. \** The Exodus software was developed primarily with funds provided by
  27. by the Defense Advanced Research Projects Agency under contracts 
  28. N00014-85-K-0788, N00014-88-K-0303,  and DAABO7-92-C-Q508 
  29. and monitored by the US Army Research Laboratory.
  30. Additional support was provided by Texas Instruments, Digital Equipment
  31. Corporation, and Apple Computer.
  32. .)f
  33. .sp 3
  34. .fo ''%''
  35. .br
  36. .sh 1 "INTRODUCTION"
  37. .pp
  38. This document describes the architecture of 
  39. Version \*V of the EXODUS Storage Manager.  
  40. It is assumed that the reader is familiar with the Storage Manager's client
  41. application interface and server process, which are described in the 
  42. [exodSM].
  43. This document is an adjunct to [exodSM], and the authors have
  44. made an effort not to repeat here anything that is contained in [exodSM].
  45. .pp
  46. The Storage Manager has a client-server architecture.  
  47. Part of the Storage Manager, called  
  48. the \fI client\fR or the \fIclient library\fR,
  49. is a library of functions that is linked with the application program.
  50. The rest of the Storage Manager, called
  51. the \fIserver\fR or \fIservers\fR,
  52. is a set of Unix processes that cooperate with the 
  53. client portions of application processes.
  54. .pp
  55. Application programs call functions in the client library
  56. to access and manipulate data in objects.  
  57. The interface between the application and the client library 
  58. consists of 
  59. a set of functions that operate on files, root entries, 
  60. objects, and indexes,
  61. and
  62. a set of options whose values are determined at run-time by 
  63. configuration files or by the application through function calls.
  64. .pp
  65. Some of the Storage Manager's work is performed by the client library
  66. in the address (process) space of the application.
  67. The rest of the work is performed by servers.
  68. Each server manages some data; each datum is managed by one server.
  69. The client library makes requests of the proper servers
  70. as its needs dictate.  
  71. The interface between the client library and the servers
  72. is a set of \fIremote procedures\fR that
  73. perform low-level services such as
  74. locking data, allocating and deallocating disk blocks, 
  75. and
  76. transaction management.
  77. .pp
  78. The remainder of this document describes in detail
  79. which functions are performed by clients and which are
  80. performed by servers.
  81. First, Section 2 describes concepts that are common to 
  82. clients and servers.
  83. Section 3 describes the client library.
  84. Section 4 presents the servers' architecture.
  85. Section 5 describes the interaction between the client and servers.
  86. Section 6 describes the interactions among servers.
  87. .sh 1 "COMMON CONCEPTS"
  88. .sh 2 "Volumes"
  89. .pp
  90. The Storage Manager stores data on \fIvolumes\fR.
  91. Volumes are Unix (TM) disk partitions or files, and have fixed sizes, in \fIblocks\fR.
  92. Blocks in a volume are numbered sequentially from the beginning of the volume.
  93. All cooperating servers and all volumes that these servers manage 
  94. must have been configured (or formatted, in the case of volumes) with the
  95. same size blocks.
  96. .sh 2 "Pages"
  97. .pp
  98. The unit of data that is 
  99. transferred between a client and a server, or between
  100. a server and a disk, is a \fIpage\fR.
  101. Pages are made of contiguous disk blocks.
  102. Each page, regardless of its size, has a \fIpage ID\fR,
  103. which is the number of the first block in the page.
  104. .pp
  105. Each page has a \fIpage type\fR.
  106. The page types are:
  107. .ip "\fIindex pages\fR" 20
  108. pages used for the keys and values in an index, or
  109. for meta-data for indexes
  110. .ip "\fIslotted pages\fR" 20
  111. pages that contain small objects, headers for large objects, and meta-data,
  112. .ip "\fIfile pages\fR" 20
  113. pages that contain meta-data to maintain files,
  114. .ip "\fIlarge-object pages\fR" 20
  115. pages that contain large objects and meta-data for large objects, 
  116. .ip "\fIlog pages\fR" 20
  117. pages that contain log records,
  118. .ip "\fIbitmap pages\fR" 20
  119. pages at the beginning of volumes that indicate which pages
  120. are free and which are in use,
  121. .ip "\fIroot entry pages\fR" 20
  122. pages at the beginning of volumes on which root
  123. entries are stored, and
  124. .ip "\fIvolume header pages\fR" 20
  125. a single page containing meta-data about the volume.
  126. .pp
  127. The Storage Manager is configured, at compile time,
  128. with a minimum page size and a size for each type of page.
  129. The minimum page size is the size of a disk block.
  130. All page sizes are a power of two
  131. and a power-of-two multiple of the disk block size.
  132. .sh 2 "Buffer Pools"
  133. .pp
  134. Each client and each server has its own \fIbuffer pool\fR, in which it 
  135. caches data from \fIsecondary storage\fR 
  136. (meaning a server, if this is a client's
  137. buffer pool, or a disk, if this is a server's buffer pool).
  138. A buffer pool, 
  139. is a fixed-size set of \fIbuffers\fR, 
  140. each the size of a disk block.
  141. Updates to data are performed in a buffer pool.
  142. Data that have been updated, but have not been written to secondary
  143. storage, are called \fIdirty\fR.
  144. Pages containing dirty data or meta-data are called \fIdirty\fR.
  145. .pp
  146. A buffer in the buffer pool
  147. holds a single minimum-page-size page.
  148. Several (contiguous) buffers may be required to
  149. hold a single (non-minimum-page-size) page.
  150. .sh 2 "Buffer Groups"
  151. .pp
  152. The buffer manager provides the concept of a \fIbuffer group\fR as 
  153. proposed in the DBMIN buffer management algorithm [Chou85].
  154. A buffer group is a collection of buffers containing \fIfixed\fR and \fIunfixed\fR pages. 
  155. Each buffer group is constrained in size and has its own replacement policy.
  156. When a set of pages is to be fixed in a buffer group, 
  157. the buffer group may contain unfixed pages that have to be  \fIswapped out\fR 
  158. to accommodate the new fixed pages.
  159. The buffer group's replacement policy determines whether the least-recently-used (LRU)
  160. or most-recently-used (MRU) unfixed pages are chosen as victims to be swapped out.
  161. .pp
  162. Dirty pages that are swapped out of a buffer group are sent to 
  163. secondary storage before their buffers are reused.
  164. The buffers that are made available during the swap
  165. are put on a list of free buffers.
  166. Those buffers that are not needed for new fixed pages remain
  167. on the free list for use by other buffer groups.
  168. An example of when this might happen is this:
  169. An LRU buffer group needs one buffer to fix a minimum-size page S.
  170. The buffer group's least-recently-used unfixed page, L, is chosen as 
  171. a victim for swapping, and L is the size of four minimum-size pages, so four
  172. buffers are freed when L is swapped out of the buffer group.
  173. Three pages remain on the free list after the swap is completed
  174. and the buffer group has fixed S. 
  175. .sh 2 "Objects, Slots, and OIDs"
  176. .pp
  177. Objects are a unit of data that the application program uses.
  178. Objects are either \fIsmall\fR or \fIlarge\fR.
  179. Small objects fit in a single slotted page.
  180. Large objects are those that do not fit in a single slotted page.
  181. Objects are identified by an OID, which contains a volume ID, a page ID,
  182. a \fIslot number\fR, and a \fIunique number\fR.
  183. .pp
  184. Slotted pages contain meta-data as well as objects:
  185. a page header and a slot array [Date81] at the end of the page.
  186. Each non-empty slot in the  array contains
  187. the offset of the object from the beginning of the page.
  188. This mechanism allows the Storage Manager to move objects on a
  189. page without affecting the integrity of data structures that reference objects on that page.
  190. An object's location within a page may change, but its OID does not.
  191. .pp
  192. Objects can move from page to page and maintain their OIDs.
  193. An object that moves to a new page becomes \fIforwarded\fR.
  194. The data on its \fIhome\fR page is the OID that identifies its new location.
  195. .pp
  196. The unique number of an OID
  197. stored in the slot array along with the object's offset from the
  198. beginning of the page.  
  199. Every time an object is accessed by its OID,
  200. the Storage Manager validates the OID by comparing the unique number
  201. in the OID with the unique number in the specified slot.  
  202. If the two differ, the OID is considered to be invalid.  
  203. The generation of unique numbers is discussed in the Appendices to [exodSM].
  204. .pp
  205. Large objects occupy slots on their home pages, and they also
  206. occupy one or more large object pages.
  207. Large object pages are dedicated to a single object.
  208. The data in large objects are stored in pages whose
  209. order and location are maintained in a B+ tree.
  210. The home page of the object, a slotted page, 
  211. points to (or includes, if the large object is small enough) 
  212. the root of the large object's tree.
  213. .sh 1 "THE CLIENT LIBRARY"
  214. .pp
  215. The Storage Manager client library is linked with an
  216. application program.  
  217. The functions in this library provide
  218. for creating, destroying, reading, writing, inserting into, deleting from, and versioning objects.  
  219. Functions are also provided for creating, destroying, accessing and modifying files of 
  220. objects and indexes.  
  221. Initialization, administration, and transaction
  222. support functions are included as well.  
  223. .lp
  224. The application program calls the 
  225. interface functions of the client library. 
  226. It does not access the server directly.  
  227. The client library functions locally
  228. perform as much work as possible,
  229. and communicate with servers when necessary.
  230. .sh 2 "Buffer Pool"
  231. .pp
  232. Applications can open buffer groups in the client buffer pool for their
  233. own purposes.
  234. The client library allocates buffer groups for its own purposes,
  235. such as for logging.
  236. Applications gain access to
  237. pages that are fixed in the client buffer pool through
  238. \fIuser descriptors\fR.
  239. Each user descriptor describes a range of bytes of 
  240. data in an object.
  241. The bytes that it describes are contiguous in the
  242. address space of the application, even if the data
  243. do not occupy contiguous pages in the volume.
  244. .pp
  245. The client's buffer manager has a complex mechanism for 
  246. allocating contiguous buffers for \fIlarge objects\fR.
  247. Different, overlapping portions of large objects can be
  248. fixed in the client's buffer pool simultaneously (through
  249. several user descriptors), and
  250. the buffer manager ensures that each such fixed portion
  251. is contiguous in the buffer pool, hence certain pages
  252. may be partially or wholly duplicated in the buffer pool.
  253. The buffer manager ensures that updates to these pages
  254. are reflected in all copies of the data.
  255. .sh 2 "Locking"
  256. .pp
  257. The client contacts servers to acquire and release 
  258. locks on pages.
  259. The client's buffer manager keeps track of the locks that it has
  260. on pages that are cached in the buffer pool,
  261. in order to minimize interaction with servers.
  262. .pp
  263. Each time the client library requests a page from a server,
  264. it also requests a lock for the page.  
  265. Locks can be \fIexclusive\fR, or \fIshared\fR, depending
  266. on the use the application is making of the data.
  267. Details on the Storage Manager's lock management are found in the 
  268. Appendices to [exodSM].
  269. .pp
  270. Lock requests are not always granted by a server.
  271. If the request would cause a deadlock, the request
  272. is denied immediately.
  273. If deadlock is not an issue, and
  274. a requested lock is held by another transaction,
  275. the lock request will wait for a time (determined by
  276. the application through the 
  277. .q locktimeout
  278. option).
  279. If the request cannot be granted in that time,
  280. it is denied.
  281. A denied lock request causes the client's operation to fail.
  282. If necessary, the failed operation 
  283. forces the client library to abort
  284. the transaction (rather than leave 
  285. data or meta-data in an inconsistent state).
  286. If the transaction is not aborted, the application
  287. may retry the operation or may abort the transaction.
  288. .sh 2 "Logging"
  289. .pp
  290. When the client updates data, it logs its updates
  291. so that the updates can be \fIundone\fR (if the transaction aborts)
  292. or \fIredone\fR (if the transaction commits and recovery is necessary after a crash).
  293. The client, however, does not have its own log; rather,
  294. it ships log records to servers.
  295. Log records describe updates to data on a single page.
  296. If several pages are updated, each update to each page
  297. merits its own log record.
  298. The log record for a page is sent to the server that manages
  299. the page in question, and it is always sent before
  300. the dirty page is sent to the server.
  301. Log records vary in size and can be very small, 
  302. so they are collected into pages and sent to
  303. the server when the pages are full.
  304. The size of a log page is determined by the server, 
  305. and it can differ from server to server.
  306. The client library caches information about the logging
  307. characteristics of each server with which it is communicating.
  308. .pp
  309. Each page has a \fIlog record count\fR (LRC).
  310. An update to a page causes its LRC to be incremented.
  311. The LRC can be considered to reflect, in some sense,
  312. the state of the page.
  313. If two copies of a given page have identical LRCs,
  314. the data in the pages are also identical. 
  315. .pp
  316. Details of the Storage Manager's logging and recovery 
  317. schemes are described in [Fran92].
  318. .sh 2 "Transactions"
  319. .pp
  320. The application can be in one of four transaction processing states 
  321. (described in [exodSM], Section 4.3.2):
  322. INACTIVE (not running a transaction), 
  323. ACTIVE (running a transaction),
  324. ABORTED (the transaction is partially aborted), 
  325. and 
  326. PREPARED (the transaction is prepared).  
  327. The client has its notion of the application's transaction state,
  328. and each server also has its notion of the same.
  329. The client and the servers' notions of this state do
  330. not always agree, because the client and servers
  331. do not always communicate on a timely basis,
  332. but eventually agreement is reached in every case.
  333. .pp
  334. When the application begins a transaction, 
  335. the client library creates a \fIlocal transaction ID\fR (TID). 
  336. The client library now considers a transaction to be ACTIVE,
  337. even though no server does.
  338. When the application calls a client library function
  339. that make a reference to data,
  340. the client library contacts the server or servers that manage the
  341. volumes of interest and
  342. establishes \fIconnections\fR with them.
  343. .pp
  344. The client library now mounts the volumes of interest and 
  345. begins transactions on each of the servers in 
  346. question, at which time each server sends the client library a
  347. \fIserver TID\fR.
  348. These servers now consider a transaction to be active, although
  349. they do not in any way recognize that they are participating
  350. in \fIthe same\fR transaction.
  351. The servers are running \fIthreads\fR of the transaction.
  352. When the client requests data and locks from a server,
  353. it identifies the transaction thread by the server's TID.
  354. .pp
  355. The application either commits or aborts the transaction.  
  356. A server may also abort a transaction for its own reasons,
  357. To commit a transaction, the client library ships all the 
  358. remaining dirty pages and their log records to the servers.
  359. If only one server is involved, the client library
  360. instructs the server to commit the transaction.  
  361. .pp
  362. If several servers are involved, the client library initiates
  363. a two-phase commit protocol.
  364. It designates one server as the coordinator, and asks the coordinator
  365. to prepare and commit the transaction.
  366. The coordinator performs the two-phase commit procedure with all
  367. the other servers, and returns the result to the client library.
  368. If the commit is successful, the client returns to the 
  369. INACTIVE state.
  370. .pp
  371. To abort a transaction, the client 
  372. discards all the pages in its buffer pool 
  373. and notifies the servers that it
  374. wishes to abort the transaction.  
  375. Again, this will place the client in the INACTIVE state.
  376. If the server 
  377. aborts a transaction, the client library is informed in the next
  378. response it receives from the server.  
  379. When it receives such a response the client moves
  380. to the ABORTED state.
  381. To end the transaction and to return to the INACTIVE state,
  382. the application program must explicitly call
  383. sm_AbortTransaction(\ ), 
  384. which notifies all the participating servers.
  385. After a transaction has been
  386. committed or aborted, the application may begin another transaction.  
  387. .pp
  388. When an application is finished using the Storage Manager,
  389. it can shut down the client library to release all the
  390. resources that the client library allocated.  
  391. The application must dismount any
  392. volumes that it mounted explicitly.
  393. .br
  394. .sh 1 "THE SERVER"
  395. .pp
  396. Loosely, the Storage Manager server can be considered to be a collection of 
  397. .q subsystems
  398. that provide different services, but the
  399. server really is a monolithic program.
  400. None of the subsystems stands alone, however,
  401. the distinction is useful for the purpose of this discussion.
  402. The rest of this section 
  403. examines how client requests are satisfied by the 
  404. server's various subsystems:
  405. threads, disk I/O, the buffer manager, files,
  406. locking, logging, and recovery,
  407. shown in Figure 1.  
  408. .(z
  409. .F+
  410. figure archfigure.psf width 6i
  411. .F-
  412. .ce 1
  413. \fBFigure 1: The Storage Manager Architecture\fR
  414. .)z
  415. .sh 2 "Threads"
  416. .pp
  417. In order to serve several clients simultaneously, and 
  418. to perform disk I/O in parallel with network I/O, the server
  419. is multi-threaded.
  420. Server threads are units of execution similar to the coroutines provided by Modula-2.  
  421. Each thread has its own stack for maintaining its execution state.  
  422. A thread is always in one of the following states: 
  423. executing, not in use,
  424. waiting on the ready queue for a chance to continue executing, 
  425. or awaiting a resource.  
  426. Resources that a thread may await include
  427. locks, latches, semaphores, 
  428. completion of disk I/O, 
  429. timers,
  430. and
  431. signals from other threads.
  432. Thread switching is implemented using the setjmp( ) and
  433. longjmp( ) functions in the standard C library.
  434. Threads are not preemptively scheduled.
  435. .pp
  436. When a client request arrives over the
  437. network, the server assigns an unused thread 
  438. to handle the request and begins executing the thread.  
  439. The thread runs until it has to wait for a resource, 
  440. voluntarily gives up the CPU, or replies to the client's request.  
  441. Threads may execute on behalf of a server task, rather than in response
  442. to a client's request. 
  443. (There are threads dedicated
  444. to timing out lock requests,
  445. taking checkpoints,  and
  446. timing out idle clients, for example.)
  447. Threads may also cooperate to accomplish a task.
  448. (For example, a thread makes a disk request
  449. on behalf of a client; another thread determines
  450. when the disk request is completed and informs the
  451. first thread of that fact.)
  452. .sh 2 "Disk I/O"
  453. .pp
  454. Since the server supports multiple clients,
  455. it is designed to avoid blocking in Unix I/O system calls.
  456. A server performs I/O locally only
  457. when there is no need for parallel I/O i.e., only when 
  458. just one client is connected and no 
  459. other threads are performing I/O on the server's behalf.
  460. .pp
  461. A server performs disk I/O for two or more volumes
  462. in parallel by forking a process for each volume when the
  463. volume is first mounted.
  464. A server thread sends I/O requests to the appropriate
  465. disk I/O process, placing itself on a wait-list so that
  466. other threads can execute.
  467. Meanwhile, the I/O process performs disk I/O on behalf of the server.
  468. The disk I/O process reads into and
  469. writes from the server's buffer pool,
  470. which is in shared memory.
  471. Servers threads can queue several requests for I/O processes simultaneously,
  472. and each request can contain a vector of pages to be written or read.
  473. .pp
  474. Once an I/O request is satisfied or terminates in error,
  475. the I/O process notifies the server and awaits its next request.
  476. The server allocates an unused thread to accept the notification, wake up the 
  477. thread that issued the request, and put itself back on the list of unused threads.
  478. .pp
  479. When the last client using a volume dismounts the volume,
  480. the server flushes all the dirty pages for that
  481. volume and issues a request to the disk I/O process to close.
  482. The disk I/O process then exits.
  483. .pp
  484. A server and its disk I/O processes use
  485. a combination of
  486. shared-memory queues,
  487. semaphores (see semctl(2))), timers (SIGALRM), and sockets
  488. to communicate with each other.
  489. For each volume, there is 
  490. a pair of queues, one for requests and the other for responses.
  491. The server places a request in the request queue.
  492. The disk process
  493. .q "moves"
  494. the request-message to the response queue by
  495. changing a single pointer that divides the two queues.
  496. Each disk I/O process polls its request queue until the queue
  497. is empty, then sleeps on a semaphore.
  498. .pp
  499. The server polls all the response queues.
  500. In fact, the server polls the response queues only when
  501. it wakes up from a
  502. select(\ ) system call.
  503. The server sets a shared-memory variable to tell the I/O processes
  504. when it is blocked on select(\ ).
  505. When it is blocked, the I/O processes 
  506. .q kick
  507. the server by sending a 1-byte message to a socket, thereby
  508. waking up the server.
  509. .sh 2 "Buffer Manager"
  510. .pp
  511. The server's buffer manager has a number of important features.
  512. The buffer manager does not contain the complex large-object
  513. buffering scheme found in the client's buffer manager,
  514. because all large-object operations are performed by the client.
  515. The buffer manager enforces a write-ahead logging protocol.  
  516. Since, unlike the client, the
  517. server is multi-threaded, the server's buffer manager also
  518. provides latches and semaphores for synchronizing threads' accesses to pages in the 
  519. buffer pool.
  520. .pp
  521. The server uses buffer groups to allocate buffer space for distinct purposes.  
  522. There is one large LRU buffer group used to satisfy client I/O requests.  
  523. Separate smaller buffer groups are used for reading and writing the log.  
  524. Smaller buffer groups are also allocated for managing the bitmap pages associated with each volume.
  525. To see how these buffer groups are used, consider the buffer
  526. group used for reading the log.  
  527. Imagine a transaction that is being aborted and that has log records on 1,000 different log 
  528. pages.  
  529. As the log pages are scanned during the undo operation, 
  530. only a few log pages are cached, subject to the
  531. size of the log-read buffer group.
  532. Without the log-read buffer group, 1,000 pages that would likely only be used 
  533. once would end up being cached.
  534. .pp
  535. The buffer manager on the server keeps track of pages that
  536. were recently swapped to disk, along with their
  537. LRCs, which reflect the pages' states.
  538. This is used for inter-transaction page caching (described in section 5.2, below).
  539. .sh 2 "Lock Manager"
  540. .pp
  541. The server's lock manager issues locks for \fIlock ID\fRs.
  542. A lock ID is a 12 byte integer.  
  543. Lock IDs are generated from 
  544. lock requests, and while they may include a page ID or a file ID,
  545. the lock manager does not interpret them as such.
  546. .pp
  547. Before a lock request is granted, the lock manager performs deadlock detection 
  548. on its local waits-for-graph (containing information for the single server only).  
  549. Servers do not perform any global deadlock detection among themselves.
  550. .pp
  551. If a lock request would result in a local deadlock,
  552. the request is not granted.
  553. If a local deadlock is not detected, the lock manager 
  554. grants the request immediately, if possible, or 
  555. puts the request on a wait-list if the lock is held by
  556. another transaction.
  557. .pp
  558. Each transaction has a lock timeout value, which determines
  559. the maximum time that the transaction will wait for a lock.
  560. If that time expires before the lock request is granted,
  561. the request is aborted, and the server replies to the
  562. client that the lock is \fIbusy\fR.
  563. This is a simple way to avoid global deadlocks.
  564. .pp
  565. Access to objects involves the standard hierarchical two-phase locking
  566. (2PL) protocol (see [Gray78] or [Gray88]).  The lock hierarchy contains
  567. two granularities: file-level, and page-level.  The page that is locked
  568. when an object is accessed is the page containing the object header.
  569. There are six lock modes: no lock (NL), share (S),
  570. exclusive (X), intent to share (IS), intent to exclusive (IX),
  571. share with intent to exclusive (SIX) [Gray78, Gray88].  
  572. Files can be locked in any of the six modes, while pages are only locked
  573. in share and exclusive mode.  
  574. .pp
  575. A table is used to determining whether two lock requests are compatible
  576. (eg., when a client holds a lock on a file and another client wants to
  577. obtain a lock on it as well). 
  578. A table of the lock compatibilities is found in the Appendices of [exodSM].
  579. .pp
  580. A table of the lock convertibility is found in the Appendices of [exodSM].
  581. .sh 2 "Logging and Recovery"
  582. .pp
  583. The Storage Manager's logging and recovery subsystem is based on the
  584. ARIES recovery algorithm [Moha89].  
  585. Details on the logging and recovery subsystems can 
  586. be found in [Fran92]  and Section 5.2.5 of [exodSM]. 
  587. .pp
  588. Each server has a log volume, which it mounts when it starts.  
  589. If the log volume is newly formatted, the server initializes the log,
  590. otherwise, the server performs recovery.  
  591. The log is managed as a circular buffer of recent log pages.
  592. When the end of the log volume is reached, log records are
  593. placed at the beginning of the log volume.
  594. Logically, the log is a sequence of log records identified by a log 
  595. sequence number (LSN).
  596. LSNs contain a physical address in the 
  597. log and a \fIwrap count\fR which is used to
  598. make LSNs unique.  
  599. .pp
  600. While generating log records, a server periodically takes a
  601. checkpoint.  
  602. The server makes a 
  603. lists of the dirty pages in the
  604. server's buffer pool, the active transactions,
  605. the volumes that are mounted, and other 
  606. state information, and writes a log record that
  607. contains these lists.
  608. Recovery, should it be needed, begins its analysis phase
  609. with the last checkpoint record written, so, 
  610. as a general rule, recovery time is 
  611. shorter if checkpoints are frequent.
  612. .pp
  613. The checkpoint frequency is determined by several factors:
  614. First, it is based on the number of log records generated.
  615. The server's 
  616. .q checkpoints
  617. option limits the number of log records that the
  618. server generates between checkpoints.
  619. The option's value can be changed while the server is running.
  620. .pp
  621. Second, the buffer manager
  622. initiates checkpoints when it invalidates
  623. a dirty page to make room for a new page being read.
  624. This causes semi-random checkpoints to be taken when
  625. the buffer pool fills with many dirty pages.
  626. .pp
  627. The server has a thread whose sole responsibility
  628. is lazily writing dirty pages to secondary storage.
  629. When a checkpoint is taken, this thread is awakened
  630. if it is not already active.
  631. By writing out dirty pages when no other server
  632. activity is going on, recovery time is reduced.
  633. .sh 2 "File Manager"
  634. .pp
  635. All Storage Manager objects are stored in \fIfiles\fR.
  636. A file is a collections of large-object pages and slotted pages,
  637. held together with a
  638. B+ tree index whose key is the page ID. 
  639. The index for a file resides on file pages.
  640. All operations that involve file pages occur on the server.
  641. File pages are never sent to clients, for two reasons.
  642. First, it eliminates the need for the complex cache 
  643. consistency system that would be required if multiple 
  644. clients were manipulating file pages.
  645. Second, the file code uses
  646. \fIsavepoints\fR [Moha89], 
  647. which are not available to clients,
  648. to back out of operations in the event of a failure.
  649. More discussion of Storage Manager files can be found in [Care86,89].
  650. .sh 1 "CLIENT-SERVER INTERACTIONS"
  651. .sh 2 "Connections"
  652. .pp
  653. When an application initializes the Storage Manager,
  654. no communication takes place between the application process and servers.
  655. The client portion of the application process contacts servers
  656. only when data are required from one or more servers.
  657. Communication between clients and servers is initiated
  658. by the clients, which open TCP connections using the 
  659. Unix (TM) Sockets interface.
  660. The TCP connection remains alive as long as the client
  661. is \fIactive\fR.
  662. .pp
  663. Servers time out any connections left over from inactive clients.
  664. A client is inactive with respect to a server if it does not have a transaction running on that server.
  665. If an application shuts the Storage Manager down, communication with servers is severed by the
  666. client library.
  667. .pp
  668. If either the client or a server
  669. closes a connection or terminates abnormally,
  670. the other process is notified by Unix.
  671. If the network breaks, both processes are notified.
  672. .pp
  673. When Unix notifies a server that a client's TCP connection has terminated 
  674. (whether due to the client's abnormal termination or a dysfunctional network),
  675. the server aborts the transaction that the client was running, 
  676. if any, and frees all the resources that the client had acquired.
  677. .pp
  678. Clients are notified of a TCP connection's abnormal termination
  679. when the they attempt to send a request or receive a response.
  680. When this occurs, the client behaves as if the server had aborted
  681. the active transaction.
  682. The application is informed of the (partially) aborted transaction
  683. the next time it tries to use the Storage Manager.
  684. It is the application's responsibility to finish aborting
  685. the transaction by calling the client library function sm_AbortTransaction(\ ),
  686. which aborts the transaction on all the participating servers
  687. and cleans up local resources associated with that transaction.
  688. .sh 2 "Inter-Transaction Page Caching"
  689. .pp
  690. When an application commits a transaction,
  691. the pages in the client buffer pool are marked
  692. \fIinvalid\fR, but are not thrown away.
  693. When a new transaction begins, 
  694. the application performs an operation on data, and
  695. the client issues a request to a server for 
  696. a page.
  697. If the client's buffer pool still contains the page
  698. in question, and the page is marked invalid,
  699. the client's request to the server contains the
  700. page's LRC.
  701. The server, when it receives such a request, checks the 
  702. LRC, and if the LRC is up-to-date, it informs the client
  703. that the client's copy of the page is up-to-date,
  704. thereby avoiding shipping an up-to-date page across the
  705. network.
  706. .pp
  707. The server keeps a list of the LRCs for pages recently
  708. swapped out, in an effort to avoid reading pages from
  709. disk only to read the page's LRC and find that the page 
  710. need not be shipped to the client.
  711. .sh 1 "SERVER-SERVER COMMUNICATION"
  712. .pp
  713. When an application uses data on several servers,
  714. the client library maintains some state information about
  715. what servers are in use for the transaction.
  716. The servers, however, have no notion that they are 
  717. participating in a distributed transaction.
  718. When the application requests the Storage Manager to
  719. commit the transaction, the client library initiates
  720. a two-phase commit procedure among the participating 
  721. servers.
  722. The client chooses a server (it does not have to be
  723. one of those participating) to coordinate the 
  724. two-phase commit protocol.
  725. That server is sent a list of the participating servers,
  726. their Internet addresses, and the transaction-identifiers
  727. by which that transaction is known to each server. 
  728. The coordinating server takes over, and when the fate of the
  729. transaction is determined, it informs the client library
  730. of the result, and terminates the interaction with other
  731. servers.
  732. .pp
  733. The two-phase commit protocol that is used by the servers
  734. is a variant of Presumed Abort (PA) [Moha83].
  735. Each server is capable of being a coordinator
  736. or a subordinate, or both.
  737. The servers communicate over UDP, using the Unix (TM) Sockets
  738. interface.
  739. .pp
  740. When a server crashes and recovers, it uses the same PA protocol to
  741. resolve transactions that were prepared under PA before the
  742. crash. 
  743. Of the recovered prepared transactions, there are
  744. two kinds.
  745. First there are the transactions that
  746. were prepared by the Storage Manager 
  747. as a result of an application's request to commit the
  748. transaction.  
  749. The server performing recovery crashed before these
  750. transactions were resolved.
  751. These transactions  
  752. are resolved (committed or aborted) by the coordinating server.
  753. .pp
  754. Second, there are 
  755. transactions that were prepared by the \fIexternal two-phase commit functions\fR
  756. (see Section 4.11.1 of [exodSM]).
  757. These transactions, after being recovered,
  758. continue to consume resources and \fBmust\fR be resolved
  759. by a recovery application in a timely fashion.
  760. .bp
  761. .ls 1
  762. .sh 1 "REFERENCES"
  763. .sp
  764. .ip "[Care86]" 10
  765. M. Carey, D. DeWitt, J. Richardson, and E. Shekita, 
  766. \fIObject and File Management in the EXODUS Extensible Database System\fR, 
  767. \fBProc. of the 1986 VLDB Conf.\fR,
  768. Kyoto, Japan, Aug. 1986.
  769. .ip "[Care89]" 10
  770. M. Carey, D. DeWitt, E. Shekita, 
  771. \fIStorage Management for Objects in EXODUS\fR,
  772. \fBObject-Oriented Concepts, Databases, and Applications\fR,
  773. W. Kim and F. Lochovsky, eds., Addison-Wesley, 1989.
  774. .ip "[Chou85]" 10
  775. H. Chou and D. Dewitt, 
  776. \fIAn Evaluation of Buffer Management Strategies for Relational Database Systems\fR,
  777. \fBProc. of the 1985 VLDB Conf.\fR, 
  778. Stockholm, Sweden, Aug. 1985.
  779. .ip "[Date81]" 10
  780. C. Date, 
  781. \fIAn Introduction to Database Systems (3rd edition)\fR,
  782. Addison-Wesley, Reading, Mass., 1981 (pg. 173).
  783. .ip "[Fran92]" 10
  784. M. Franklin, M. Zwilling, C.K.Tan, M. Carey, and D. DeWitt,
  785. \fICrash Recovery in Client-Server EXODUS\fR,
  786. \fBProc. of the ACM SIGMOD Int'l. Conf. on Management of Data\fR,
  787. San Diego, CA, June 1992.
  788. .ip "[Gray78]" 10
  789. J. N. Gray,
  790. \fINotes on Database Operating Systems\fR,
  791. \fBLecture Notes in Computer Science 60, 
  792. Advanced course on Operating Systems\fR,
  793. ed. G. Seegmuller, Springer Verlag, New York 1978.
  794. .ip "[Gray88]" 10
  795. J. Gray, R. Lorie, G. Putzolu, I. Traiger,
  796. \fIGranularity of Locks and Degrees of Consistency in a Shared Data Base\fR,
  797. \fBReadings in Database Systems\fR,
  798. ed. M. Stonebraker, Morgan Kaufmann, San Mateo, Ca., 1988.
  799. .ip "[Moha83]" 10
  800. C. Mohan, B. Lindsay,
  801. \fIEfficient Commit Protocols for the Tree of Processes 
  802. Model of Distributed Transactions\fR,
  803. \fBProc. 2nd ACM SIGACT/SIGOPS Symposium on Principles of Distributed
  804. Computing\fR,
  805. Montreal, Canada, August, 1983.
  806. .ip "[Moha89]" 10
  807. C. Mohan, D. Haderle, B. Lindsay, H. Pirahesh, and P. Schwarz,
  808. \fIARIES: A Transaction Recovery Method Supporting
  809. Fine-Granularity Locking and Partial Rollbacks Using Write-Ahead
  810. Logging\fR, 
  811. \fIACM Transactions on Database Systems\fR,
  812. Vol. 17, No 1, March 1992.
  813. .ip "[exodSM]" 10
  814. \fIUsing the EXODUS Storage Manager V\*V\fR,
  815. unpublished,
  816. included in EXODUS Storage Manager software release.
  817.